<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
       <el-form-item label="账号" prop="target_account">
        <el-input v-model="formInline.target_account" placeholder="请输入账号" @keyup.enter.native="$emit('on-filter',formInline)" > </el-input>
      </el-form-item>
      <el-form-item label="昵称" prop="target_nick">
        <el-input v-model="formInline.target_nick" placeholder="请输入昵称" @keyup.enter.native="$emit('on-filter',formInline)" > </el-input>
      </el-form-item>
      <el-form-item label="操作人" prop="account">
        <el-input v-model="formInline.account" placeholder="请输入" @keyup.enter.native="$emit('on-filter',formInline)" > </el-input>
      </el-form-item>
      <el-form-item label="操作类型" prop="type">
        <el-select v-model="formInline.type" placeholder="操作类型">
          <el-option
            v-for="item in typeList"
            :label="item.title"
            :key="item.value"
            :value="item.value"

          ></el-option>
        </el-select>
      </el-form-item >
      <el-form-item label="禁言时长" prop="ttl">
        <el-select v-model="formInline.ttl" placeholder="禁言时长">
          <el-option
            v-for="item in timeList"
            :label="(item.value==0?'':item.value)+(item.unit==0?'永久':(item.unit==1?'分钟':(item.unit==2?'小时':(item.unit==3?'天':'全部'))))"
            :key="item.id"
            :value="item.ttl"

          ></el-option>
        </el-select>
      </el-form-item >
      <el-form-item label="禁言类别" prop="cate">
        <el-select v-model="formInline.cate" placeholder="禁言类别">
          <el-option
            v-for="item in cateList"
            :label="item.name"
            :key="item.value"
            :value="item.name"

          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-col>
          <el-form-item prop="time" label="操作时间">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              :default-time="['00:00:00', '23:59:59']"
              :picker-options="pickerWeekStep">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>

      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
import { form, grid, pickerOption } from '@/build';
import { getcate, getBannedTime } from '@/services/api/chatRoom';


export default {
  name: 'form-filter',
  mixins: [form, grid, pickerOption],
  data() {
    return {
      typeList: [
        { title: '全部', value: undefined },
        { title: '禁言', value: '1' },
        { title: '人工解禁', value: '2' },
        { title: '自动解禁', value: '3' },
        { title: '忽略', value: '4' },
      ],
      cateList: [],
      timeList: [],
      ReportType: [], // 举报类别
      auditFirList: [],
      auditSecList: [],
      formInline: {
        time: [
          moment().format('YYYY-MM-DD 00:00:00'),
          moment().format('YYYY-MM-DD 23:59:59'),
        ],
        account: '',
        target_nick: '',
        target_account: '',
        ttl: '',
        cate: '',
        type: '',
        page: 1,
        size: 20,
      },

    };
  },
  methods: {
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$emit('on-filter', this.formInline);
    },
  },
  mounted() {
    this.bindGet(getcate, 'cateList', {
      sendingData: {},
      format: (data) => {
        data.unshift({
          id: undefined,
          name: '全部',
          value: undefined,
        });
        return data;
      },
    });
    this.bindGet(getBannedTime, 'timeList', {
      sendingData: {},
      format: (data) => {
        data.unshift({
          id: undefined,
          name: '全部',
          value: '',
          unit: '全部',
          ttl: '',
        });
        return data;
      },
    });

    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
